<template>
  <div class="wrapper">
    <swiper :options="swiperOption" ref="mySwiper" @someSwiperEvent="callback" v-if="show">
      <swiper-slide v-for="item in swiperList" :key="item.id">
        <img class="swiper-img" :src="item.imgUrl">
      </swiper-slide>
      <div class="swiper-pagination"  slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
export default {
  name: 'HomeSwiper',
  props: {
    swiperList: {
      type: Array
    }
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        autoplay: 3000,
        speed: 300,
        loop: true
      }
    }
  },
  methods: {
    callback () {}
  },
  computed: {
    show () {
      return this.swiperList.length
    }
  }
}
</script>

<style lang="stylus" scoped>
  // 样式穿透，在wrapper类下只要出现swiper-pagination-bullet类名的样式都不被scoped干扰，不这样被scoped干扰样式不起效
  .wrapper >>> .swiper-pagination-bullet
    background-color #fff
  .wrapper
    width: 100%
    height 0
    padding-bottom: 31.25%// 宽的31.25%
    overflow hidden
    background-color #eee
    .swiper-img
      width: 100%
</style>
